//
//  WYCShimingController.m
//  掌上还
//
//  Created by 中企互联 on 2018/1/10.
//  Copyright © 2018年 中企互联. All rights reserved.
//

#import "WYCShimingController.h"

@interface WYCShimingController ()<UITableViewDelegate,UITableViewDataSource>
/** 列表*/
@property(nonatomic,strong)UITableView * tableView;


/** 姓名*/
@property(nonatomic,strong)UILabel * name;
/** 姓名*/
@property(nonatomic,strong)UILabel * sex;
/** 姓名*/
@property(nonatomic,strong)UILabel * address;
/** 姓名*/
@property(nonatomic,strong)UILabel * num;
/** 姓名*/
@property(nonatomic,strong)UILabel * birth;
/** 姓名*/
@property(nonatomic,strong)UILabel * nationality;
@end

@implementation WYCShimingController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = WYCGlobalBg;
    [self setupTableView];
    
    [self setupRequster];
}

- (void)setupRequster{
    NSString * str = [NSString stringWithFormat:@"%@token=%@",usergetIdDetail,[WYCAccountTool unarchivetoken]];
    
    [HttpTool POST:str params:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        WYCLog(@"------------------%@",responseObject);
        if ([[responseObject objectForKey:@"code"] intValue] == 0){
            NSDictionary * dict = [responseObject objectForKey:@"result"];
            self.name.text = [dict objectForKey:@"name"];
            self.sex.text = [dict objectForKey:@"sex"];
            self.address.text = [dict objectForKey:@"address"];
            NSString * birthStr = [dict objectForKey:@"birth"];
            
            NSArray * arr  = [birthStr componentsSeparatedByString:@" "];
            self.birth.text = [NSString stringWithFormat:@"%@",arr[0]];
            self.num.text = [dict objectForKey:@"num"];
            self.nationality.text = [dict objectForKey:@"nationality"];
           
        }else{
            
            [self showToast:msgStr];
        }
    } fail:^(NSURLSessionDataTask *task, NSError *error) {
        [self showToast:Failed];
    }];
    
}
- (void)addclick{
    
    
}
- (void)setupTableView{
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
   
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavHeight, ScreenWidth, WYCcellHeight * 7 + 50 * px) style:UITableViewStylePlain];
    self.tableView.backgroundColor = WYCGlobalBg;
    self.tableView.dataSource = self;
    self.tableView.scrollEnabled = NO;
    self.tableView.delegate = self;
//    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    [self.view addSubview:self.tableView];
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 6;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return WYCcellHeight;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    tableView.tableFooterView = [[UIView alloc] init];
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"123"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"123"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    CGFloat cellX = 40 * px;
    CGFloat cellY = 40 * px;
    CGFloat cellW = ScreenWidth;
    CGFloat imageW = 80 * px;
    //    CGFloat imageH = 80 * px;
    
    if (indexPath.row == 0) {
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(cellX, cellY, 100 * px, imageW);
        pushtitle.text = @"姓名";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
        
        self.name = [[UILabel alloc] init];
        self.name.frame = CGRectMake(CGRectGetMaxX(pushtitle.frame), cellY, ScreenWidth - 200 * px, imageW);
        self.name.textAlignment = NSTextAlignmentRight;
        self.name.font = [UIFont systemFontOfSize:WyzFont];
        self.name.textColor = WYCRGBColor(167, 175, 179);
        [cellView addSubview:self.name];
        
    }else if (indexPath.row == 1){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(cellX, cellY, 100 * px, imageW);
        pushtitle.text = @"性别";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
        
        self.sex = [[UILabel alloc] init];
        self.sex.frame = CGRectMake(ScreenWidth - 80 * px - 200 * px, cellY, 200 * px, imageW);
//        name.text = [WYCAccountTool ];
        self.sex.textAlignment = NSTextAlignmentRight;
        self.sex.textColor = WYCRGBColor(167, 175, 179);
        self.sex.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:self.sex];
    }else if (indexPath.row == 2){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(cellX, cellY, 100 * px, imageW);
        pushtitle.text = @"民族";
        
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
        
        self.nationality = [[UILabel alloc] init];
        self.nationality.frame = CGRectMake(ScreenWidth - 80 * px - 200 * px, cellY, 200 * px, imageW);
        self.nationality.textAlignment = NSTextAlignmentRight;
        self.nationality.font = [UIFont systemFontOfSize:WyzFont];
        self.nationality.textColor = WYCRGBColor(167, 175, 179);
        [cellView addSubview:self.nationality];
    }else if (indexPath.row == 3){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(cellX, cellY, 100 * px, imageW);
        pushtitle.text = @"出生";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
        
        self.birth = [[UILabel alloc] init];
        self.birth.frame = CGRectMake(CGRectGetMaxX(pushtitle.frame), cellY, ScreenWidth - 200 * px, imageW);
        self.birth.textAlignment = NSTextAlignmentRight;
        self.birth.textColor = WYCRGBColor(167, 175, 179);
        self.birth.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:self.birth];
    }else if (indexPath.row == 4){
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        [cell addSubview:cellView];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(cellX, cellY, 100 * px, imageW);
        pushtitle.text = @"住址";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
        
        self.address = [[UILabel alloc] init];
        self.address.frame = CGRectMake(CGRectGetMaxX(pushtitle.frame), cellY, ScreenWidth - 200 * px, imageW);
        self.address.text = [WYCAccountTool unarchivebankName];
        self.address.textAlignment = NSTextAlignmentRight;
        self.address.textColor = WYCRGBColor(167, 175, 179);
        self.address.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:self.address];
    }else{
        UIView * cellView = [[UIView alloc] init];
        cellView.frame = CGRectMake(0, 0, ScreenWidth, cell.height);
        //        cellView.backgroundColor = WYCGlobalBg;
        [cell addSubview:cellView];
        
        UILabel * pushtitle = [[UILabel alloc] init];
        pushtitle.frame = CGRectMake(cellX, cellY, 200 * px, imageW);
        pushtitle.text = @"身份证号";
        pushtitle.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:pushtitle];
        
        self.num = [[UILabel alloc] init];
        self.num.frame = CGRectMake(CGRectGetMaxX(pushtitle.frame), cellY, ScreenWidth - 280 * px, imageW);
        self.num.textAlignment = NSTextAlignmentRight;
        self.num.textColor = WYCRGBColor(167, 175, 179);
        self.num.font = [UIFont systemFontOfSize:WyzFont];
        [cellView addSubview:self.num];
        
        
    }
    
    return cell;
}
- (void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    UIView * NavView = [[UIView alloc] init];
    NavView.frame = CGRectMake(0, 0, ScreenWidth, NavHeight);
    NavView.backgroundColor = WYCmainColor;
    [self.view addSubview:NavView];
    
    
    
    CALayer *bottomLineLayer = [[CALayer alloc] init];
    bottomLineLayer.frame = CGRectMake(0, NavView.bounds.size.height - 0.5, NavView.bounds.size.width, 0.5);
    bottomLineLayer.backgroundColor = WYCmainColor.CGColor;
    [NavView.layer addSublayer:bottomLineLayer];
    
    
    //返回按钮
    UIButton *  backbutton = [[UIButton alloc] init];
    //        [backbutton setImage:[UIImage imageNamed:@"add"] forState:UIControlStateNormal];
    [backbutton setTitle:@"已认证" forState:UIControlStateNormal];
    backbutton.frame = CGRectMake(NavView.width - 226 * px, titleY, 200 * px , 68 * px);
    backbutton.titleLabel.font = [UIFont systemFontOfSize:BigFont];
    backbutton.contentHorizontalAlignment= UIControlContentHorizontalAlignmentRight;
    [NavView addSubview:backbutton];
    
    
    //返回按钮
    UIButton *  fanhuibutton = [[UIButton alloc] init];
    [fanhuibutton setImage:[UIImage imageNamed:@"Nav_back"] forState:UIControlStateNormal];
    [fanhuibutton addTarget:self action:@selector(photoClick) forControlEvents:UIControlEventTouchUpInside];
    fanhuibutton.frame = CGRectMake(30 * px, titleY, 66 * px , 66 * px);
    [NavView addSubview:fanhuibutton];
    
    
    UILabel * NavRigsterLabel = [[UILabel alloc] init];
    NavRigsterLabel.frame = CGRectMake(0, titleY, NavView.width, 68 * px);
    NavRigsterLabel.textColor = [UIColor whiteColor];
    NavRigsterLabel.font = [UIFont boldSystemFontOfSize:BigFont];
    NavRigsterLabel.textAlignment = NSTextAlignmentCenter;
    NavRigsterLabel.text = @"实名认证";
    [NavView addSubview:NavRigsterLabel];
}

- (void)photoClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}
@end
